#include <iostream>
#include <vector>
#include <string>


using namespace std;

class Solution1 {
public:
    int combinationSum4(vector<int>& nums, int target) {
        vector<unsigned int> dp(target + 1);
        dp[0] = 1;
        for (int j = 1; j <= target; ++j)
        {
            for (int num : nums)
            {
                if (j >= num)
                    dp[j] += dp[j - num];
            }
        }
        return dp[target];
    }
};

int score(char c)
{
    switch (c)
    {
    case 'l': return 4;
    case 'o': return 3;
    case 'v': return 2;
    case 'e': return 1;
    default: return 0;
    };
    return 0;
}

int main()
{
    int n, m; cin >> n >> m;
    vector<string> g(n);
    for (int i = 0; i < n; ++i)
        cin >> g[i];

    vector<vector<int>> dp(n, vector<int>(m, 0));
    dp[0][0] = score(g[0][0]);
    for (int i = 1; i < m; ++i) dp[0][i] = dp[0][i - 1] + score(g[0][i]);
    for (int i = 1; i < n; ++i) dp[i][0] = dp[i - 1][0] + score(g[i][0]);

    for (int i = 1; i < n; ++i)
        for (int j = 1; j < m; ++j)
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + score(g[i][j]);

    cout << dp[n - 1][m - 1];

    return 0;
}